package com.akupilih.app.helper;

import android.content.Context;
import android.widget.Toast;

import com.android.volley.NetworkError;
import com.android.volley.NoConnectionError;
import com.android.volley.ServerError;
import com.android.volley.TimeoutError;
import com.android.volley.VolleyError;

public class VolleyHelper {

	/**
	 * show volley error
	 * 
	 * @param context
	 * @param error
	 */
	public static void showVolleyError(Context context, VolleyError error) {
		if (error instanceof NetworkError) {
			Toast.makeText(context, "Network Error", Toast.LENGTH_SHORT).show();
		} else if (error instanceof ServerError) {
			Toast.makeText(context,
					"Server Error" + error.networkResponse.statusCode,
					Toast.LENGTH_SHORT).show();
		} else if (error instanceof NoConnectionError) {
			Toast.makeText(context, "No Connection Error", Toast.LENGTH_SHORT)
					.show();
		} else if (error instanceof TimeoutError) {
			Toast.makeText(context, "NetworkTimeOut", Toast.LENGTH_SHORT)
					.show();
		}
	}

}
